package com.luwanglin;

import com.luwanglin.service.HelloService;
import sun.misc.Service;

import java.util.Iterator;
import java.util.ServiceLoader;

public class App {
    public static void main(String[] args) {
        System.out.println(" ======= 方式二 ＝＝＝＝＝＝＝＝＝＝＝＝＝");
        Iterator<HelloService> providers = Service.providers(HelloService.class);
        while (providers.hasNext()) {
            HelloService service = providers.next();
            service.sayHello();
        }

        System.out.println(" ======= 方式二 ＝＝＝＝＝＝＝＝＝＝＝＝＝");
        ServiceLoader<HelloService> load = ServiceLoader.load(HelloService.class);
        for (HelloService ser : load) {
            ser.sayHello();
        }

    }
}
